package com.kdgz.kdgz.config;

import com.kdgz.kdgz.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Desc 自定义Springboot配置类
 * @date 2021/3/17
 */
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {

    /**
     * 添加拦截器
     *
     * @param registry 注册
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**") // 添加拦截路径
                .excludePathPatterns("/","/login","/index.html","/css/**","/js/**","/pic/**","/register"); // 放行路径
    }
}
